<!--
 * @Description: 
 * @Date: 2023-03-27 14:22:27
 * @LastEditors: czp
 * @LastEditTime: 2023-05-06 15:36:43
-->
<template>
	<el-config-provider :locale="i18nLocale">
		<!-- <el-scrollbar height="100vh"> -->
		<BaseNavbar v-if="$route.path != '/'" />
		<!--通过route里面的属性进行判断-->
		<router-view v-if="$route.meta.alive" v-slot="{ Component }">
			<keep-alive> <component :is="Component" /> </keep-alive>
		</router-view>

		<!--不想要缓存的页面-->
		<router-view v-if="!$route.meta.alive"></router-view>
		<!-- </el-scrollbar> -->
	</el-config-provider>
</template>
<script setup lang="ts">
import en from "element-plus/es/locale/lang/en";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import zhTw from "element-plus/es/locale/lang/zh-tw";
import ja from "element-plus/es/locale/lang/ja";
import ko from "element-plus/es/locale/lang/ko";

import { storeToRefs } from "pinia";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { useBaseStore } from "./store/base";
import { getBrowserLang } from "./utils/utils";
import { useResize } from "./hook/useResize";
import { useWxSdk } from "./hook/useWxSdk";
const $route = useRoute();

// 获取基础配置
const baseStore = useBaseStore();
// 获取当前语言
const { language } = storeToRefs(baseStore);
// 设置当前语言
const i18n = useI18n();
const i18nLocale = computed(() => {
	if (!language.value) language.value = getBrowserLang() == "zh" ? "zh-cn" : "en";
	i18n.locale.value = language.value;

	if (language.value == "zh-cn") return zhCn;
	if (language.value == "zh-tw") return zhTw;
	if (language.value == "en") return en;
	if (language.value == "ja") return ja;
	if (language.value == "ko") return ko;
});

// 获取菜单列表
const { getMenuList } = baseStore;
getMenuList();
useResize();
useWxSdk();
</script>
<style lang="scss">
html,
body,
#app {
	width: 100%;
	min-height: 100%;
	padding: 0;
	margin: 0;
}
body {
	padding: 0;
	margin: 0;
}
</style>
